var UL_REPLIES = "replyList";

if (!readOnly) {
    $(function() {
        $( "#" + UL_REPLIES ).sortable({
            revert: true,
            stop: function() {
                populateUserList();
            }
        });
        $( "ul, li" ).disableSelection();
        populateUserList();
    });
}

function element(id) {
    return document.getElementById(id);
}

function populateUserList() {
    element("userList").value = buildUserList();
}

function buildUserList() {
    var userLst = [];
    var ul = element(UL_REPLIES);
    for (var i =0; i < ul.children.length; i++) {
        userLst[i] = ul.children[i].id.split("-")[1];
    }
    return userLst.join(",");
}
